/*    */ package bdSQL;
/*    */ 
/*    */ import java.sql.Connection;
/*    */ import java.sql.DriverManager;
/*    */ import java.sql.ResultSet;
/*    */ import java.sql.SQLException;
/*    */ import java.sql.Statement;
/*    */ 
/*    */ public class Banco
/*    */ {
/*    */   private static final String SERVIDOR = "logan";
/*    */   private static final String DATABASE = "Bd_Transporte";
/*    */   private static final String USUARIO = "sa";
/*    */   private static final String SENHA = "1234";
/* 16 */   private static Banco instance = null;
/*    */ 
/*    */   public static synchronized Banco getInstance()
/*    */   {
/* 20 */     if (instance == null) {
/* 21 */       instance = new Banco();
/*    */     }
/* 23 */     return instance;
/*    */   }
/*    */ 
/*    */   public static Connection conecta() throws Exception
/*    */   {
/*    */     try
/*    */     {
/* 30 */       Class.forName("net.sourceforge.jtds.jdbc.Driver");
/* 31 */       return DriverManager.getConnection("jdbc:jtds:sqlserver://10.104.0.123:1433/Bd_Transporte", 
/* 32 */         "sa", "1234");
/*    */     } catch (Exception e) {
/* 34 */       e.printStackTrace();
/*    */     }
/* 36 */     return null;
/*    */   }
/*    */ 
/*    */   public boolean verificaConectividadeComBanco() throws Exception
/*    */   {
/*    */     try {
/* 42 */       if (conecta() != null)
/* 43 */         return true;
/*    */     } catch (Exception e) {
/* 45 */       e.printStackTrace();
/*    */     }
/* 47 */     return false;
/*    */   }
/*    */ 
/*    */   public ResultSet consulta(String sql) throws Exception
/*    */   {
/* 52 */     Connection conexao = conecta();
/* 53 */     if (conexao != null) {
/* 54 */       Statement stm = conexao.createStatement();
/* 55 */       return stm.executeQuery(sql);
/*    */     }
/* 57 */     return null;
/*    */   }
/*    */ 
/*    */   public boolean executa(String sql) {
/*    */     try {
/* 62 */       Statement stm = null;
/* 63 */       Connection conexao = conecta();
/* 64 */       if (conexao != null) {
/* 65 */         stm = conexao.createStatement();
/* 66 */         if (stm.execute(sql))
/* 67 */           return true;
/*    */       }
/*    */     }
/*    */     catch (Exception e) {
/* 71 */       e.printStackTrace();
/* 72 */       return false;
/*    */     }
/* 74 */     return false;
/*    */   }
/*    */ 
/*    */   public static int numLinhas(ResultSet rs) {
/* 78 */     ResultSet rs2 = rs;
/* 79 */     int contador = 0;
/* 80 */     if (rs2 != null)
/*    */       try {
/* 82 */         while (rs2.next())
/* 83 */           contador++;
/*    */       }
/*    */       catch (SQLException e) {
/* 86 */         e.printStackTrace();
/*    */       }
/* 88 */     rs2 = null;
/* 89 */     return contador;
/*    */   }
/*    */ 
/*    */   public static void main(String[] args)
/*    */     throws SQLException
/*    */   {
/*    */   }
/*    */ }

/* Location:           C:\Users\samuel\Desktop\
 * Qualified Name:     bdSQL.Banco
 * JD-Core Version:    0.6.2
 */